#ifndef SMOOTHWINDOWZOOMANIMATION_H
#define SMOOTHWINDOWZOOMANIMATION_H

#include <windows.h>
#include <WindowsX.h>
#include <map>

class SmoothWindowZoomAnimation;

#include "Utilities.h"
#include "WindowEdge.h"

using namespace std;

class SmoothWindowZoomAnimation
{
public:
	typedef void (*WNDZOOMANIMATIONPROC)(SmoothWindowZoomAnimation* sender, int currentValue);

	SmoothWindowZoomAnimation(HWND hWnd);
	~SmoothWindowZoomAnimation();
	
	HWND GetHWnd();
	bool IsRunning();
	bool StartAnimation(int speed, int windowEdgeStartValue, int amount, WindowEdge windowEdge);
	bool CancelAnimation();

	void AnimationStarted(WNDZOOMANIMATIONPROC ptr);
	void AnimationCancelled(WNDZOOMANIMATIONPROC ptr);
	void AnimationFinished(WNDZOOMANIMATIONPROC ptr);
private:
	int speed;
	int amount;
	int counter;
	int windowEdgeStartValue;
	int windowEdgeCurrentValue;
	double factor;

	bool increment;
	bool timerEnabled;

	WindowEdge windowEdge;
	POINT startPoint;
	HWND hWnd;


	WNDZOOMANIMATIONPROC onAnimationStartedPtr;
	WNDZOOMANIMATIONPROC onAnimationCancelledPtr;
	WNDZOOMANIMATIONPROC onAnimationFinishedPtr;


	int Round(double x);
	void StartTimer();
	void StopTimer();	
	void Animate();
	void CallWndZoomAnimationEvent(WNDZOOMANIMATIONPROC ptr, SmoothWindowZoomAnimation* sender, int currentValue);


	static map<HWND, SmoothWindowZoomAnimation*> instances;

	static VOID CALLBACK TimerProc(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
};

#endif